using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace IReaper.Initializer
{
    public class CheckNewVersionTask:AbstractInitTask
    {
        protected override void JobContent()
        {
            try
            {
                this.InitManager.SetMessage(Properties.Resources.CheckNewVersion);
                WebClient client = new WebClient();
                string versionString = client.DownloadString(Properties.Settings.Default.VersionCheckURL);
                Version newVersion = new Version(versionString);
                Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
                Core.CoreData[CoreDataType.HasNewVersion] =  newVersion.CompareTo(currentVersion) > 0;
            }
            catch
            {
                Core.CoreData[CoreDataType.HasNewVersion] = false;
                return; 
            }
        }
    }
}
